#!/usr/bin/env python
# -*- conding: utf-8 -*-

"""
@Time     : 2024/8/30 7:20
@Author   : liujingmao
@File     : 1.Runnable重试机制.py
"""

from langchain_core.runnables import RunnableLambda

counter = -1


def func(x):
    global counter
    counter += 1
    print(f"当前的值为{counter=}")
    return x / counter


chain = RunnableLambda(func).with_retry(stop_after_attempt=2)

resp = chain.invoke(10)

print(resp)
